﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using Maticsoft.Common;
using LTP.Accounts.Bus;
namespace MidSoft.Web.Model_T_SYS_PETBREED
{
    public partial class Modify : Page
    {       

        		protected void Page_Load(object sender, EventArgs e)
		{
			if (!Page.IsPostBack)
			{
				#warning 代码生成提示：显示页面,请检查确认该语句是否正确
				ShowInfo();
			}
		}
			
	private void ShowInfo()
	{
		MidSoft.BLL.BLL_T_SYS_PETBREED bll=new MidSoft.BLL.BLL_T_SYS_PETBREED();
		MidSoft.Model.Model_T_SYS_PETBREED model=bll.GetModel();
		this.txtSYS_PETBREED_ID.Text=model.SYS_PETBREED_ID;
		this.txtREG_ORG_ID.Text=model.REG_ORG_ID;
		this.txtHELP_CODE.Text=model.HELP_CODE;
		this.txtNAME.Text=model.NAME;
		this.txtCREATOR_ID.Text=model.CREATOR_ID;
		this.txtCREATOR_NAME.Text=model.CREATOR_NAME;
		this.txtUPDATE_TIME.Text=model.UPDATE_TIME.ToString();
		this.txtUPDATOR_ID.Text=model.UPDATOR_ID;
		this.txtUPDATOR_NAME.Text=model.UPDATOR_NAME;
		this.txtCREATE_TIME.Text=model.CREATE_TIME.ToString();
		this.txtID.Text=model.ID.ToString();

	}

		public void btnSave_Click(object sender, EventArgs e)
		{
			
			string strErr="";
			if(this.txtSYS_PETBREED_ID.Text.Trim().Length==0)
			{
				strErr+="ID不能为空！\\n";	
			}
			if(this.txtREG_ORG_ID.Text.Trim().Length==0)
			{
				strErr+="注册组织ID不能为空！\\n";	
			}
			if(this.txtHELP_CODE.Text.Trim().Length==0)
			{
				strErr+="快速输入码不能为空！\\n";	
			}
			if(this.txtNAME.Text.Trim().Length==0)
			{
				strErr+="品种名称不能为空！\\n";	
			}
			if(this.txtCREATOR_ID.Text.Trim().Length==0)
			{
				strErr+="创建人ID不能为空！\\n";	
			}
			if(this.txtCREATOR_NAME.Text.Trim().Length==0)
			{
				strErr+="创建人姓名不能为空！\\n";	
			}
			if(!PageValidate.IsDateTime(txtUPDATE_TIME.Text))
			{
				strErr+="更新时间格式错误！\\n";	
			}
			if(this.txtUPDATOR_ID.Text.Trim().Length==0)
			{
				strErr+="更新人ID不能为空！\\n";	
			}
			if(this.txtUPDATOR_NAME.Text.Trim().Length==0)
			{
				strErr+="更新人姓名不能为空！\\n";	
			}
			if(!PageValidate.IsDateTime(txtCREATE_TIME.Text))
			{
				strErr+="创建时间格式错误！\\n";	
			}
			if(!PageValidate.IsDecimal(txtID.Text))
			{
				strErr+="原ID格式错误！\\n";	
			}

			if(strErr!="")
			{
				MessageBox.Show(this,strErr);
				return;
			}
			string SYS_PETBREED_ID=this.txtSYS_PETBREED_ID.Text;
			string REG_ORG_ID=this.txtREG_ORG_ID.Text;
			string HELP_CODE=this.txtHELP_CODE.Text;
			string NAME=this.txtNAME.Text;
			string CREATOR_ID=this.txtCREATOR_ID.Text;
			string CREATOR_NAME=this.txtCREATOR_NAME.Text;
			DateTime UPDATE_TIME=DateTime.Parse(this.txtUPDATE_TIME.Text);
			string UPDATOR_ID=this.txtUPDATOR_ID.Text;
			string UPDATOR_NAME=this.txtUPDATOR_NAME.Text;
			DateTime CREATE_TIME=DateTime.Parse(this.txtCREATE_TIME.Text);
			decimal ID=decimal.Parse(this.txtID.Text);


			MidSoft.Model.Model_T_SYS_PETBREED model=new MidSoft.Model.Model_T_SYS_PETBREED();
			model.SYS_PETBREED_ID=SYS_PETBREED_ID;
			model.REG_ORG_ID=REG_ORG_ID;
			model.HELP_CODE=HELP_CODE;
			model.NAME=NAME;
			model.CREATOR_ID=CREATOR_ID;
			model.CREATOR_NAME=CREATOR_NAME;
			model.UPDATE_TIME=UPDATE_TIME;
			model.UPDATOR_ID=UPDATOR_ID;
			model.UPDATOR_NAME=UPDATOR_NAME;
			model.CREATE_TIME=CREATE_TIME;
			model.ID=ID;

			MidSoft.BLL.BLL_T_SYS_PETBREED bll=new MidSoft.BLL.BLL_T_SYS_PETBREED();
			bll.Update(model);
			Maticsoft.Common.MessageBox.ShowAndRedirect(this,"保存成功！","list.aspx");

		}


        public void btnCancle_Click(object sender, EventArgs e)
        {
            Response.Redirect("list.aspx");
        }
    }
}
